package com.jxaummd.mushroom.core.util.tool.time;

import com.blankj.utilcode.util.TimeUtils;

import java.text.SimpleDateFormat;

public class MTimeUtils {

    public static final String[]  WeekToNumber = {"一","二","三","四","五","六","日"};

    /**
     * 从名字获取星期的数字
     * @return
     */
    public static int getNowIntheWeek (){
        String week = TimeUtils.millis2String(TimeUtils.getNowMills(),new SimpleDateFormat("E"));
        for(int i=0;i<7;i++){
            if(week.contains(WeekToNumber[i])){
                return i+1;
            }
        }
        return 7;
    }

    /**
     * 从名字获取星期的数字
     * @return
     */
    public static String getNowMonth (){
        String week = TimeUtils.millis2String(TimeUtils.getNowMills(),new SimpleDateFormat("MM"));
        return week;
    }

    /**
     * 从名字获取星期的数字
     * @return
     */
    public static String getNowDay (){
        String week = TimeUtils.millis2String(TimeUtils.getNowMills(),new SimpleDateFormat("dd"));
        return week;
    }


    /**
     * 从名字获取星期的数字
     * @return
     */
    public static String getNowHour(){
        String week = TimeUtils.millis2String(TimeUtils.getNowMills(),new SimpleDateFormat("HH"));
        return week;
    }


    /**
     * 从名字获取星期的数字
     * @param week
     * @return
     */
    public static int gettheWeek (String week){
        for(int i=0;i<7;i++){
            if(week.contains(WeekToNumber[i])){
                return i;
            }
        }
        return 6;
    }

    public static void main(String[] args) {
        System.out.println(getNowMonth());
        System.out.println(getNowDay());
        System.out.println(getNowHour());
    }
}
